import {
  splitToLength,
  BoolStrWithBoolen,
  BoolStrWithNumber,
  splitToArray,
} from '../../../Utils/common'
export function sub5(data) {
  console.log('************convertWithSub5-1 in************************')
  const {
    attr49,
    attr50,
    attr51,
    attr52,
    attr53,
    attr54,
    attr55,
    attr56,
    attr57,
    attr58,
    attr59,
    attr60,
    attr61,
    recurrenceAfterStop,
    attr62,
    attr63,
  } = data
  let str = ''
  str += attr49to50Convert(attr49, attr50)

  str += attr51to55Convert(attr51, attr52, attr53, attr54, attr55)

  if (attr56) str += `\n既往使用过${attr56}等控制药物治疗，`

  str += attr57to61Convert(attr57, attr58, attr59, attr60, attr61)

  if (recurrenceAfterStop) {
    str += `停药后${recurrenceAfterStop}再次发作，`
  }

  if (BoolStrWithBoolen(attr62) !== '')
    str += `\n两次发作之间${attr62}完全缓解期`

  if (attr63) str += `，其他：${attr63}`
  console.log('************convertWithSub5-1 out************************')
  return str
}
function attr49to50Convert(
  attr49,
  attr50,
  attr51,
  attr52,
  attr53,
  attr54,
  attr55,
  attr56,
  attr57,
  attr58,
  attr59,
  attr60,
  attr61
) {
  const b = BoolStrWithBoolen(attr49)
  if (b === false) return '未曾使用过哮喘药物治疗，'
  if (b === '') return ''
  let str = ''
  if (b) str += '曾使用过哮喘药物治疗，'
  if (attr50) str += `既往使用过${attr50}等缓解药物治疗，`
  return str
}

function attr51to55Convert(attr51, attr52, attr53, attr54, attr55) {
  let str = ''
  const time = timeToStr(attr51, attr52, attr53, attr54)
  str += time
  const b1 = BoolStrWithBoolen(attr55)
  if (b1 === false) str += '无效。'
  if (b1) str += '有效。'
  return str
}

function attr57to61Convert(attr57, attr58, attr59, attr60, attr61) {
  let str = ''
  const time = timeToStr(attr57, attr58, attr59, attr60)
  str += time
  const b1 = BoolStrWithBoolen(attr61)
  if (b1 === false) str += '无效。'
  if (b1) str += '有效。'
  return str
  // let str = ''
  // const b1 = BoolStrWithBoolen(attr55)
  // if (b1 === false) str += '无效。'
  // if (b1) str += '有效。'
  // const time = timeToStr(attr51, attr52, attr53, attr54)
  // str += time
  // return str
}

function timeToStr(year, month, week, day) {
  let str = ''
  if (year) str += `${year}年`
  if (month) str += `${month}月`
  if (week) str += `${week}周`
  if (day) str += `${day}日`
  if (str) {
    str = '，使用长达' + str + '，'
  }
  return str
}
